<template>
	<view class="chapter-content">
		<view class="student-item" v-for="(item,index) in list" :key="index">
			<view class="student-item_name">{{item.name}}</view>
			<view class="student-item_right">
				<!-- <view class="student-item_type text_gray">设备连接中...</view> -->
				<!-- <view class="student-item_type text_green">体测完成</view> -->
				<view class="student-item_type text_active">去体测</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getstudentList,
		getTrainingSend
	} from "../../../static/js/api/training.js"
	export default {
		data() {
			return {
				list: [{
					name: '111',
				}, {
					name: '222',
				}],
				selectedIndexs: [],
				params: {},
			}
		},
		onLoad(option) {
			console.log(option.params)
			if (option.params) {
				this.params = JSON.parse(option.params)
				// this.getData()
				uni.setNavigationBarTitle({
					title: `组织学生进行体测 ${this.params.section_name}${this.params.grade_name} ${this.params.class_name} 学生列表`
				})
			}
		},
		methods: {
			getData() {
				getstudentList({
					class_id: this.params.class_id,
					t: this.params.t,
				}).then(res => {
					console.log(res.students)
					this.list = res.students

				})
			},
			// 查看
			handleSee(item) {
				console.log(item)
				uni.navigateTo({
					url: '/pages/releasePlan/release/sportsTesting'
				})
			},
			selectChange(e) {
				this.selectedIndexs = e.detail.index
				console.log(this.selectedIndexs)
			},
			save() {
				if (this.selectedIndexs.length == 0) {
					uni.showToast({
						title: "请选择学生",
						icon: "none"
					})
				} else {
					let ids = []
					this.list.forEach((item, index) => {
						this.selectedIndexs.forEach(indexItem => {
							if (index == indexItem) {
								ids.push(item.id)
							}
						})
					})
					let studentIds = ids.toString()
					uni.navigateTo({
						url: '/pages/releasePlan/release/chapter?studentIds=' + studentIds + '&class_id=' + this
							.params.class_id
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import url("./index.scss");

	.text_black {
		color: $uni-text-color-black;
	}

	.text_opblack {
		color: $uni-text-color-opblack;
	}

	.text_active {
		background-color: $uni-color-primary;
	}

	.text_green {
		background-color: $uni-color-success;
	}

	.text_gray {
		background-color: #B7B7B7;
	}
</style>